package controller

import (
	myConfig "common/config"
	"common/helper"
	myredis "common/redis"
	"common/userHelp"
	myUserHelp "common/userHelp"
	"encoding/json"
	"errors"
	"fmt"
	"github.com/valyala/fasthttp"
	"member/contrib/validator"
	"member/model"
	"strconv"
	"strings"
	"time"
)

type MemberController struct{}

type memberRegParam struct {
	LinkID     string `json:"link_id"` //上级id 对应邀请链接注册
	RegUrl     string `json:"reg_url"`
	Email      string `json:"email"`
	DeviceNo   string `json:"device_no"`
	Password   string `json:"password"`
	Phone      string `json:"phone"`
	Sid        string `json:"sid"`
	Ts         string `json:"ts"`
	VerifyCode string `json:"verify_code"`
	BusinessId string `json:"business_id"` //业务员id 对应业务员链接注册
	ChannelId  string `json:"channel_id"`  //渠道id 对应渠道链接注册
	RealName   string `json:"real_name"`   //真实名称
	Currency   string `json:"currency"`    //货币
	Username   string `json:"username"`    //货币
}

type loginParam struct {
	DeviceNo string `json:"device_no"`
	Vid      string `json:"vid"`
	Code     string `json:"code"`
	Username string `json:"username"`
	Password string `json:"password"`
}

// 修改用户密码参数
type forgetPassword struct {
	Sid      string `json:"sid"`
	Ts       string `json:"ts"`
	Code     string `json:"code"`
	Phone    string `json:"phone"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

/*
查询充值分成记录
*/
type ShareRecordtemParam struct {
	BeginTime int   `json:"beginTime"`
	EndTime   int   `json:"endTime"`
	Level     int   `json:"level"`
	PageIndex int32 `json:"pageIndex"`
	PageCount int32 `json:"pageCount"`
}

type ShareRecordTotal struct {
	Amount        float64 `db:"amount" json:"amount"`
	RechargeShare float64 `db:"recharge_share" json:"recharge_share"`
}

type ShareRecordItem struct {
	Uid           int     `db:"uid" json:"uid"`
	Nickname      string  `db:"nickname" json:"nickname"`
	ParentId      int     `db:"parent_id" json:"parent_id"`
	Amount        float64 `db:"amount" json:"amount"`
	Level         int     `db:"level" json:"level"`
	RechargeRate  float64 `db:"recharge_rate" json:"recharge_rate"`
	RechargeShare float64 `db:"recharge_share" json:"recharge_share"`
	CreateAt      int     `db:"create_at" json:"create_at"`
}

type ShareRecord struct {
	RecordCount int                 `db:"recordCount" json:"recordCount"`
	Total       [3]ShareRecordTotal `db:"Total" json:"Total"`
	Items       []ShareRecordItem   `db:"Items" json:"Items"`
}

func (that *MemberController) RechargeShareRecord(ctx *fasthttp.RequestCtx) {
	valUid := model.GetUidFromToken(ctx)
	if valUid == "" {
		helper.Print(ctx, false, helper.AccessTokenExpires)
		return
	}

	param := ShareRecordtemParam{}

	dataBody := ctx.PostBody()
	err := json.Unmarshal(dataBody, &param)
	if err != nil {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	if param.Level > 3 {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	//先查询总条数跟汇总
	var record ShareRecord
	sqlSelect := fmt.Sprintf("select count(1) as recordCount "+
		" from tbl_rec_recharge_share as a"+
		" left join tbl_deposit as b "+
		" on a.orderId=b.id"+
		" where a.parent_id=%s and a.state=1 and b.hidden=0", valUid)
	if param.Level != 0 {
		sqlSelect += fmt.Sprintf(" and level=%d", param.Level)
	}

	if param.BeginTime != 0 && param.EndTime != 0 {
		sqlSelect += fmt.Sprintf(" and create_at>=%d and create_at<=%d", param.BeginTime, param.EndTime)
	}

	//获取总的记录数量
	helper.InfoLog("1111  %s", sqlSelect)
	model.GetMasterDBInstance().Get(&record.RecordCount, sqlSelect)

	//获取1级的汇总
	var AmountLv1 float64 = 0.00
	var RechargeShareLv1 float64 = 0.00
	sqlSelect = fmt.Sprintf("select IFNULL(SUM(a.amount-a.hidden_amount), 0)  as amount "+
		" from tbl_rec_recharge_share as a"+
		" left join tbl_deposit as b "+
		" on a.orderId=b.id"+
		" where a.parent_id=%s and a.level=1 and a.state=1  and b.hidden=0", valUid)
	model.GetMasterDBInstance().Get(&AmountLv1, sqlSelect)
	record.Total[0].Amount = AmountLv1

	sqlSelect = fmt.Sprintf("select IFNULL(SUM(recharge_share), 0)  as recharge_share "+
		" from tbl_rec_recharge_share"+
		" where parent_id=%s and level=1 and state=1 ", valUid)
	model.GetMasterDBInstance().Get(&RechargeShareLv1, sqlSelect)
	record.Total[0].RechargeShare = RechargeShareLv1

	//获取1级的汇总
	var AmountLv2 float64 = 0.00
	var RechargeShareLv2 float64 = 0.00
	sqlSelect = fmt.Sprintf("select IFNULL(SUM(a.amount-a.hidden_amount), 0)  as amount "+
		" from tbl_rec_recharge_share as a"+
		" left join tbl_deposit as b "+
		" on a.orderId=b.id"+
		" where a.parent_id=%s and a.level=2 and a.state=1  and b.hidden=0", valUid)
	model.GetMasterDBInstance().Get(&AmountLv2, sqlSelect)
	record.Total[1].Amount = AmountLv2

	sqlSelect = fmt.Sprintf("select IFNULL(SUM(recharge_share), 0)  as recharge_share "+
		" from tbl_rec_recharge_share"+
		" where parent_id=%s and level=2 and state=1 ", valUid)
	model.GetMasterDBInstance().Get(&RechargeShareLv2, sqlSelect)
	record.Total[1].RechargeShare = RechargeShareLv2

	//获取1级的汇总
	var AmountLv3 float64 = 0.00
	var RechargeShareLv3 float64 = 0.00
	sqlSelect = fmt.Sprintf("select IFNULL(SUM(a.amount-a.hidden_amount), 0)  as amount "+
		" from tbl_rec_recharge_share as a"+
		" left join tbl_deposit as b "+
		" on a.orderId=b.id"+
		" where a.parent_id=%s and a.level=3 and a.state=1  and b.hidden=0", valUid)
	model.GetMasterDBInstance().Get(&AmountLv3, sqlSelect)
	record.Total[2].Amount = AmountLv3

	sqlSelect = fmt.Sprintf("select IFNULL(SUM(recharge_share), 0)  as recharge_share "+
		" from tbl_rec_recharge_share"+
		" where parent_id=%s and level=3 and state=1 ", valUid)
	model.GetMasterDBInstance().Get(&RechargeShareLv3, sqlSelect)
	record.Total[2].RechargeShare = RechargeShareLv3

	sqlSelect = fmt.Sprintf("select a.uid,a.nickname,a.parent_id,(a.amount-a.hidden_amount) as amount,a.level,a.recharge_rate,a.recharge_share,a.create_at "+
		" from tbl_rec_recharge_share as a"+
		" left join tbl_deposit as b "+
		" on a.orderId=b.id"+
		" where a.parent_id=%s and a.state=1 and b.hidden=0", valUid)

	if param.Level != 0 {
		sqlSelect += fmt.Sprintf("and a.level=%d", param.Level)
	}

	if param.BeginTime != 0 && param.EndTime != 0 {
		sqlSelect += fmt.Sprintf(" and a.create_at>=%d and a.create_at<=%d", param.BeginTime, param.EndTime)
	}

	sqlSelect += fmt.Sprintf(" order by create_at")
	sqlSelect += fmt.Sprintf("  LIMIT %d OFFSET %d", param.PageCount, param.PageIndex*param.PageCount)

	helper.InfoLog("5555  %s", sqlSelect)
	err = model.GetMasterDBInstance().Select(&record.Items, sqlSelect)
	if err != nil {
		helper.SqlSelectErrLog("%s--%s", sqlSelect, err.Error())
	}
	helper.Print(ctx, true, record)
}

/*
充值分成的信息
*/
type RechargeShareInfo struct {
	EnableRechargeShare float64 `db:"EnableRechargeShare" json:"EnableRechargeShare"` //可领取金额
	HasRechargeShare    float64 `db:"HasRechargeShare" json:"HasRechargeShare"`       //已领取金额
}

func (that *MemberController) GetRechargeShareInfo(ctx *fasthttp.RequestCtx) {

	valUid := model.GetUidFromToken(ctx)
	if valUid == "" {
		helper.Print(ctx, false, helper.AccessTokenExpires)
		return
	}

	var shareInfo RechargeShareInfo
	sqlSelect := fmt.Sprintf("select enable_recharge_share_lv1 + enable_recharge_share_lv2 + enable_recharge_share_lv3 from tbl_member_return where uid=%s", valUid)
	selectErr := model.GetMasterDBInstance().Get(&shareInfo.EnableRechargeShare, sqlSelect)
	if selectErr != nil {
		helper.InfoLog("[GetRechargeShareInfo]:%s error:%s", sqlSelect, selectErr.Error())
	}

	sqlSelect = fmt.Sprintf("select ifnull(sum(enable_recharge_share),0) as enable_recharge_share from tbl_proxy_accu where uid=%s", valUid)
	selectErr = model.GetMasterDBInstance().Get(&shareInfo.HasRechargeShare, sqlSelect)
	if selectErr != nil {
		helper.InfoLog("[GetRechargeShareInfo]:%s error:%s", sqlSelect, selectErr.Error())
	}
	helper.Print(ctx, true, shareInfo)
	return
}

/*
领取充值分成
*/

type EnableRechargeShare struct {
	Enable_recharge_share_lv1 float64 `db:"enable_recharge_share_lv1" json:"enable_recharge_share_lv1"`
	Enable_recharge_share_lv2 float64 `db:"enable_recharge_share_lv2" json:"enable_recharge_share_lv2"`
	Enable_recharge_share_lv3 float64 `db:"enable_recharge_share_lv3" json:"enable_recharge_share_lv3"`
}

func (that *MemberController) RechargeShare(ctx *fasthttp.RequestCtx) {

	valUid := model.GetUidFromToken(ctx)
	if valUid == "" {
		helper.Print(ctx, false, helper.AccessTokenExpires)
		return
	}

	if myConfig.IsActiveOpen(myConfig.ActiveType_RechargeShare) == 0 {
		helper.Print(ctx, false, helper.AppActiveClose)
		return
	}

	lockKey := valUid + "RechargeShare"
	if !myredis.Lock(model.GetRedisInstance(), lockKey) {
		helper.GetloggerInstance().Criticalf("lockError:%s", lockKey)
		return
	}

	defer myredis.Unlock(model.GetRedisInstance(), lockKey)

	var enableItem EnableRechargeShare
	sqlSelect := fmt.Sprintf("select enable_recharge_share_lv1, enable_recharge_share_lv2, enable_recharge_share_lv3 from tbl_member_return where uid=%s", valUid)
	model.GetMasterDBInstance().Get(&enableItem, sqlSelect)

	if enableItem.Enable_recharge_share_lv1+enableItem.Enable_recharge_share_lv2+enableItem.Enable_recharge_share_lv3 == 0.0 {
		helper.Print(ctx, true, 0)
		return
	}

	if enableItem.Enable_recharge_share_lv1 > 0.00 {
		myUserHelp.AddBalanceTransactionRecord(valUid, enableItem.Enable_recharge_share_lv1,
			helper.TransactionRechargeShareBonuslv1, "0", helper.GenId(), 0.00, "", "", 0)
		myUserHelp.AddUserWageItem(valUid, enableItem.Enable_recharge_share_lv1, helper.TransactionRechargeShareBonuslv1)
		myUserHelp.AddUserBalanceByFloat64(valUid, enableItem.Enable_recharge_share_lv1)
		myUserHelp.ClearEnableRechargeShare(valUid, 1)

		_, errExec := model.GetMasterDBInstance().Exec("CALL tbl_report_proxy_change_update(?,?,?,?)", valUid,
			helper.TransactionRechargeShareBonuslv1, enableItem.Enable_recharge_share_lv1, time.Now().Unix())
		if errExec != nil {
			helper.GetloggerInstance().Emergencyf("CALL tbl_report_proxy_change_update(%s,%d,%0.2f,%d);	reason:%s",
				valUid, helper.TransactionRechargeShareBonuslv1, enableItem.Enable_recharge_share_lv1, time.Now().Unix(), errExec.Error())
		}
		_, errExec = model.GetMasterDBInstance().Exec("CALL tbl_report_user_change_update(?,?,?,?)", valUid, helper.TransactionRechargeShareBonuslv1, enableItem.Enable_recharge_share_lv1, time.Now().Unix())
		if errExec != nil {
			helper.GetloggerInstance().Emergencyf("CALL tbl_report_user_change_update(%s,%d,%0.2f,%d);	reason:%s",
				valUid, helper.TransactionRechargeShareBonuslv1, enableItem.Enable_recharge_share_lv1, time.Now().Unix(), errExec.Error())
		}
	}

	if enableItem.Enable_recharge_share_lv2 > 0.00 {
		myUserHelp.AddBalanceTransactionRecord(valUid, enableItem.Enable_recharge_share_lv2,
			helper.TransactionRechargeShareBonuslv2, "0", helper.GenId(), 0.00, "", "", 0)
		myUserHelp.AddUserWageItem(valUid, enableItem.Enable_recharge_share_lv2, helper.TransactionRechargeShareBonuslv2)
		myUserHelp.AddUserBalanceByFloat64(valUid, enableItem.Enable_recharge_share_lv2)
		myUserHelp.ClearEnableRechargeShare(valUid, 2)

		_, errExec := model.GetMasterDBInstance().Exec("CALL tbl_report_proxy_change_update(?,?,?,?)", valUid,
			helper.TransactionRechargeShareBonuslv2, enableItem.Enable_recharge_share_lv2, time.Now().Unix())
		if errExec != nil {
			helper.GetloggerInstance().Emergencyf("CALL tbl_report_proxy_change_update(%s,%d,%0.2f,%d);	reason:%s",
				valUid, helper.TransactionRechargeShareBonuslv2, enableItem.Enable_recharge_share_lv2, time.Now().Unix(), errExec.Error())
		}
		_, errExec = model.GetMasterDBInstance().Exec("CALL tbl_report_user_change_update(?,?,?,?)", valUid, helper.TransactionRechargeShareBonuslv2, enableItem.Enable_recharge_share_lv2, time.Now().Unix())
		if errExec != nil {
			helper.GetloggerInstance().Emergencyf("CALL tbl_report_user_change_update(%s,%d,%0.2f,%d);	reason:%s",
				valUid, helper.TransactionRechargeShareBonuslv2, enableItem.Enable_recharge_share_lv2, time.Now().Unix(), errExec.Error())
		}
	}

	if enableItem.Enable_recharge_share_lv3 > 0.00 {
		myUserHelp.AddBalanceTransactionRecord(valUid, enableItem.Enable_recharge_share_lv3,
			helper.TransactionRechargeShareBonuslv3, "0", helper.GenId(), 0.00, "", "", 0)
		myUserHelp.AddUserWageItem(valUid, enableItem.Enable_recharge_share_lv3, helper.TransactionRechargeShareBonuslv3)
		myUserHelp.AddUserBalanceByFloat64(valUid, enableItem.Enable_recharge_share_lv3)
		myUserHelp.ClearEnableRechargeShare(valUid, 3)

		_, errExec := model.GetMasterDBInstance().Exec("CALL tbl_report_proxy_change_update(?,?,?,?)", valUid,
			helper.TransactionRechargeShareBonuslv3, enableItem.Enable_recharge_share_lv3, time.Now().Unix())
		if errExec != nil {
			helper.GetloggerInstance().Emergencyf("CALL tbl_report_proxy_change_update(%s,%d,%0.2f,%d);	reason:%s",
				valUid, helper.TransactionRechargeShareBonuslv3, enableItem.Enable_recharge_share_lv3, time.Now().Unix(), errExec.Error())
		}
		_, errExec = model.GetMasterDBInstance().Exec("CALL tbl_report_user_change_update(?,?,?,?)", valUid, helper.TransactionRechargeShareBonuslv3, enableItem.Enable_recharge_share_lv3, time.Now().Unix())
		if errExec != nil {
			helper.GetloggerInstance().Emergencyf("CALL tbl_report_user_change_update(%s,%d,%0.2f,%d);	reason:%s",
				valUid, helper.TransactionRechargeShareBonuslv3, enableItem.Enable_recharge_share_lv3, time.Now().Unix(), errExec.Error())
		}
	}

	helper.Print(ctx, true, enableItem.Enable_recharge_share_lv1+enableItem.Enable_recharge_share_lv2+enableItem.Enable_recharge_share_lv3)
	return
}

type VipInfoItem struct {
	Level      int64   `db:"level" json:"level"`
	CanBonus   int64   `db:"canBonus" json:"canBonus"`
	ValidWaged float64 `db:"validWaged" json:"validWaged"`
}

func (that *MemberController) VipInfo(ctx *fasthttp.RequestCtx) {

	uid := model.GetUidFromToken(ctx)
	if uid == "" {
		helper.Print(ctx, false, helper.AccessTokenExpires)
		return
	}

	var data VipInfoItem
	data.Level = userHelp.GetVipLevel(uid)
	data.ValidWaged = userHelp.GetTotalWaged(uid)
	data.CanBonus = 0
	if userHelp.CanMonthBonus(uid) || userHelp.CanWeekBonus(uid) || userHelp.CanUpBonus(uid) {
		data.CanBonus = 1
	}

	helper.Print(ctx, true, data)
}
func (that *MemberController) Info(ctx *fasthttp.RequestCtx) {

	uid := model.GetUidFromToken(ctx)
	if uid == "" {
		helper.Print(ctx, false, helper.AccessTokenExpires)
		return
	}

	mb, ret := myUserHelp.GetMemberBaseInfoByUid(uid)
	if !ret {
		helper.Print(ctx, false, helper.UserNotExist)
		return
	}

	helper.Print(ctx, true, mb)
}

func (that *MemberController) Token(ctx *fasthttp.RequestCtx) {

	uid := model.GetUidFromToken(ctx)
	if uid == "" {
		helper.Print(ctx, false, helper.AccessTokenExpires)
		return
	}

	mb, ret := myUserHelp.GetMemberBaseInfoByUid(uid)
	if !ret {
		helper.Print(ctx, false, helper.UserNotExist)
		return
	}

	mb.CreatedAt = 0
	mb.Password = ""

	helper.Print(ctx, true, mb)
}

func (that *MemberController) LastWinRecord(ctx *fasthttp.RequestCtx) {

	a, err := model.LastWinRecord()
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}

	helper.Print(ctx, true, a)
}

func (that *MemberController) Login(ctx *fasthttp.RequestCtx) {
	param := loginParam{}
	data := ctx.PostBody()
	err := json.Unmarshal(data, &param)
	if err != nil {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}
	if param.Username == "" {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}
	//if !validator.CtypeAlnum(param.Password) {
	if !validator.CheckUPassword(param.Password, 6, 20) {
		helper.Print(ctx, false, helper.PasswordFMTErr)
		return
	}

	device := string(ctx.Request.Header.Peek("d"))
	//prefix := string(ctx.Request.Header.Peek("X-Prefix"))
	prefix := helper.GetSourceFromRequest(ctx)
	i, err := strconv.Atoi(device)
	if err != nil {
		helper.Print(ctx, false, helper.DeviceTypeErr)
		return
	}

	if _, ok := model.Devices[i]; !ok {
		helper.Print(ctx, false, helper.DeviceTypeErr)
		return
	}

	ip := helper.FromRequest(ctx)
	var (
		phone string
		email string
	)
	if strings.Contains(param.Username, "@") {
		email = param.Username
	} else {
		phone = param.Username
	}

	id, err := model.MemberLogin(ctx, prefix, param.Vid, param.Code, phone, email, param.Password, ip, device, param.DeviceNo)
	if err != nil {
		if err.Error() == helper.Blocked || err.Error() == helper.UserNotExist ||
			err.Error() == helper.DeviceBanErr || strings.Contains(err.Error(), helper.IpBanErr) {
			helper.Print(ctx, false, err.Error())
			return
		}

		helper.Print(ctx, false, err.Error())
		return
	}

	ctx.Response.Header.Set("id", id)
	helper.Print(ctx, true, helper.Success)
}

func (that *MemberController) Reg(ctx *fasthttp.RequestCtx) {

	param := memberRegParam{}
	data := ctx.PostBody()

	err := json.Unmarshal(data, &param)
	if err != nil {
		helper.InfoLog("[Reg:json.Unmarshal]:%s", err.Error())
		helper.Print(ctx, false, helper.ParamErr)
		return
	}
	//linkId 取前8位数字
	var LinkId string
	for _, r := range param.LinkID {
		if r >= '0' && r <= '9' {
			LinkId += fmt.Sprintf("%c", r)
			if len(LinkId) == 8 {
				break
			}
		}
	}

	if len(LinkId) > 0 && len(LinkId) != 8 {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	param.LinkID = LinkId

	//channel_id 取前6位数字
	var ChannelId string
	for _, r := range param.ChannelId {
		if r >= '0' && r <= '9' {
			ChannelId += fmt.Sprintf("%c", r)
			if len(ChannelId) == 6 {
				break
			}
		}
	}

	if len(ChannelId) > 0 && len(ChannelId) != 6 {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	param.ChannelId = ChannelId

	//business_id 取前7位数字
	var BusinessId string
	for _, r := range param.BusinessId {
		if r >= '0' && r <= '9' {
			BusinessId += fmt.Sprintf("%c", r)
			if len(BusinessId) == 7 {
				break
			}
		}
	}

	if len(BusinessId) > 0 && len(BusinessId) != 7 {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	param.BusinessId = BusinessId

	if param.LinkID != "" {
		if !validator.CheckStringDigit(param.LinkID) {
			helper.InfoLog("[Reg:CheckStringDigit]:%s,%s", helper.InviteCodeErr, param.LinkID)
			helper.Print(ctx, false, helper.InviteCodeErr)
			return
		}
	}

	if myConfig.GetGameCfgInt(myConfig.CfgUnRegControl) == 1 {
		if param.ChannelId == "888888" {
			helper.InfoLog("[Reg:BanRegErr]:ChannelId=%s", param.ChannelId)
			helper.Print(ctx, false, helper.BanRegErr)
			return
		}
		if param.ChannelId == "" && param.LinkID == "" && param.BusinessId == "" {
			helper.InfoLog("[Reg:BanRegErr]:ChannelId=%s,LinkID=%s", param.ChannelId, param.LinkID)
			helper.Print(ctx, false, helper.BanRegErr)
			return
		}
	}

	if !validator.CheckUPassword(param.Password, 6, 20) {
		helper.InfoLog("[Reg:CheckUPassword]:%s", helper.PasswordFMTErr)
		helper.Print(ctx, false, helper.PasswordFMTErr)
		return
	}

	ip := helper.FromRequest(ctx)
	createdAt := uint32(ctx.Time().Unix())
	device := string(ctx.Request.Header.Peek("d"))
	i, err := strconv.Atoi(device)
	if err != nil {
		helper.InfoLog("[Reg:strconv.Atoi]:%s", helper.DeviceTypeErr)
		helper.Print(ctx, false, helper.DeviceTypeErr)
		return
	}

	if _, ok := model.Devices[i]; !ok {
		helper.InfoLog("[Reg:Devices]:%s", helper.DeviceTypeErr)
		helper.Print(ctx, false, helper.DeviceTypeErr)
		return
	}

	//prefix := string(ctx.Request.Header.Peek("X-Prefix"))
	prefix := helper.GetSourceFromRequest(ctx)
	helper.InfoLog("GetSourceFromRequest:%s", prefix)
	extendParams := map[string]interface{}{
		"Currency": param.Currency,
		"RealName": param.RealName,
		"Username": param.Username,
	}
	// 注册地址 去除域名前缀
	uid, err := model.MemberReg(
		i,
		prefix,
		param.Sid,
		param.Email,
		param.Password,
		ip,
		param.DeviceNo,
		param.RegUrl,
		param.LinkID,
		param.Phone,
		param.Ts,
		param.BusinessId,
		param.ChannelId,
		createdAt,
		extendParams,
	)
	if err != nil {
		helper.InfoLog("[Reg:model.MemberReg]:%s", err.Error())
		helper.Print(ctx, false, err.Error())
		return
	}

	ctx.Response.Header.Set("id", uid)
	helper.Print(ctx, true, helper.Success)
}

// 会员账号是否可用
func (that *MemberController) Valid(ctx *fasthttp.RequestCtx) {

	username := strings.ToLower(string(ctx.QueryArgs().Peek("username")))
	//字母数字组合，4-9，前2个字符必须为字母
	if !validator.CheckUName(username, 5, 14) {
		helper.Print(ctx, false, helper.UsernameErr)
		return
	}

	// 检测会员是否已注册
	if model.MemberExist(username) {
		helper.Print(ctx, false, helper.UsernameExist)
		return
	}

	helper.Print(ctx, true, helper.Success)
}

func (that *MemberController) Logout(ctx *fasthttp.RequestCtx) {

	model.MemberLogout(ctx)
	helper.Print(ctx, true, helper.Success)
}

func (that *MemberController) Nav(ctx *fasthttp.RequestCtx) {

	res, err := model.MemberNav()
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}

	ctx.SetBody(res)
}

// CheckUserAccount 验证用户
func (that *MemberController) CheckUserAccount(ctx *fasthttp.RequestCtx) {
	params := forgetPassword{}
	err := func(ctx *fasthttp.RequestCtx, params *forgetPassword) error {
		data := ctx.PostBody()
		e := json.Unmarshal(data, &params)
		if e != nil {
			return errors.New(helper.ParamErr)
		}
		if params.Username == "" {
			return errors.New(helper.UserNotExist)
		}
		val, err := model.GetMemberByUsernameOrPhone(params.Username)
		if err != nil {
			return errors.New(err.Error())
		}
		if val.Phone == "" {
			return errors.New(helper.MobileNoVerfiy)
		}
		var phoneLength = len(val.Phone)
		var maxLength = 8
		if phoneLength < maxLength {
			maxLength = phoneLength
		}
		res := map[string]interface{}{
			"phone": fmt.Sprintf("%s******%s", val.Phone[0:2], val.Phone[maxLength:]),
		}
		helper.Print(ctx, true, res)
		return nil
	}(ctx, &params)
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}
}

// CheckUserPhoneAndSendSms 验证用户手机并发送短信
func (that *MemberController) CheckUserPhoneAndSendSms(ctx *fasthttp.RequestCtx) {
	params := forgetPassword{}
	err := func(ctx *fasthttp.RequestCtx, params *forgetPassword) error {
		data := ctx.PostBody()
		e := json.Unmarshal(data, &params)
		if e != nil {
			return errors.New(helper.ParamErr)
		}
		if params.Username == "" {
			return errors.New(helper.UserNotExist)
		}
		if params.Phone == "" {
			return errors.New(helper.MobileNoVerfiy)
		}
		val, err := model.GetMemberByUsernameOrPhone(params.Username)
		if err != nil {
			return errors.New(err.Error())
		}
		if params.Phone != val.Phone {
			return errors.New(helper.PhoneNumberErr)
		}
		day := ctx.Time().Format("0102")
		sip := helper.FromRequest(ctx)
		phone := fmt.Sprintf("55%s", val.Phone)
		id, ts, err := model.SendSms(
			phone,
			day,
			sip,
			"2",
			fmt.Sprintf(`%d`, 2),
		)
		//id, ts, err := day, fmt.Sprintf("%s-%s", sip, phone), nil
		if err != nil {
			return errors.New(err.Error())
		}
		helper.Print(ctx, true, map[string]interface{}{
			"sid": id,
			"ts":  strconv.FormatInt(ts, 10),
		})
		return nil
	}(ctx, &params)
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}
}

// 用户忘记密码
func (that *MemberController) ForgetPassword(ctx *fasthttp.RequestCtx) {

	params := forgetPassword{}
	data := ctx.PostBody()
	err := json.Unmarshal(data, &params)
	if err != nil {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	if !validator.CheckUPassword(params.Password, 6, 20) {
		helper.Print(ctx, false, helper.PasswordFMTErr)
		return
	}

	ip := helper.FromRequest(ctx)
	prefix := helper.GetSourceFromRequest(ctx)
	err = model.MemberForgetPwd(params.Password, params.Phone, params.Email, ip, params.Sid, params.Code, params.Ts, prefix)
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}

	helper.Print(ctx, true, helper.Success)
}

type changePasswordParam struct {
	OldPassword     string `json:"old_password"`
	Password        string `json:"password"`
	ConfirmPassword string `json:"confirm_password"`
}

func (that *MemberController) Balance(ctx *fasthttp.RequestCtx) {

	uid := model.GetUidFromToken(ctx)
	if uid == "" {
		helper.Print(ctx, false, helper.AccessTokenExpires)
		return
	}

	a, err := myUserHelp.GetMemberBalanceInfo(uid)
	a.UnlockAmount = myUserHelp.GetEnableWithdrawMount(uid)
	if !err {
		helper.Print(ctx, false, helper.UserNotExist)
		return
	}

	helper.Print(ctx, true, a)
}

// 用户修改密码
func (that *MemberController) UpdatePassword(ctx *fasthttp.RequestCtx) {

	params := changePasswordParam{}
	data := ctx.PostBody()
	err := json.Unmarshal(data, &params)
	if err != nil {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	if !validator.CheckUPassword(params.Password, 6, 20) {
		helper.Print(ctx, false, helper.PasswordFMTErr)
		return
	}

	if params.ConfirmPassword != params.Password {
		helper.Print(ctx, false, helper.PasswordInconsistent)
		return
	}

	err = model.MemberPasswordUpdate(params.OldPassword, params.Password, ctx)
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}

	helper.Print(ctx, true, helper.Success)
}

type updatePasswordParam struct {
	UpdateType      int    `json:"update_type"` // 1 新增密码 2 修改旧密码 3 忘记密码，通过验证码重置
	Ty              int    `json:"ty"`
	Sid             string `json:"sid"`
	Ts              string `json:"ts"`
	Code            string `json:"code"`
	ConfirmPassword string `json:"confirm_password"`
	Password        string `json:"password"`
	Old             string `json:"old"`
	Phone           string `json:"phone"`
}

// 用户修改密码
func (that *MemberController) UpdatePayPassword(ctx *fasthttp.RequestCtx) {

	params := updatePasswordParam{}
	data := ctx.PostBody()
	err := json.Unmarshal(data, &params)
	if err != nil {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	t := map[int]bool{
		1: true,
		2: true,
	}
	if _, ok := t[params.Ty]; !ok {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}
	//if !validator.CtypeAlnum(params.Password) { //支持数字和字母
	//	//if !validator.CtypeDigit(params.Password) { //只支持数字
	//	helper.Print(ctx, false, helper.PasswordFMTErr)
	//	return
	//}

	err = model.MemberPayPasswordUpdate(params.UpdateType, params.Ty, params.Sid, params.Code, params.ConfirmPassword, params.Password, params.Ts, params.Old, params.Phone, ctx)
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}

	helper.Print(ctx, true, helper.Success)
}

type bindEmailParam struct {
	Sid   string `json:"sid"`
	Ts    string `json:"ts"`
	Code  string `json:"code"`
	Email string `json:"email"`
}

// 用户绑定邮箱
func (that *MemberController) BindEmail(ctx *fasthttp.RequestCtx) {

	params := bindEmailParam{}
	data := ctx.PostBody()
	err := json.Unmarshal(data, &params)
	if err != nil {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	if params.Email == "" || !strings.Contains(params.Email, "@") {
		helper.Print(ctx, false, helper.EmailFMTErr)
		return
	}

	ip := helper.FromRequest(ctx)
	err = model.CheckEmailCaptcha(ip, params.Sid, params.Email, params.Code)
	if err != nil {
		helper.Print(ctx, false, helper.EmailVerificationErr)
		return
	}

	err = model.MemberUpdateEmail(params.Email, params.Ts, ctx)
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}

	helper.Print(ctx, true, helper.Success)
}

type bindPhoneParam struct {
	Phone string `json:"phone"`
	Ts    string `json:"ts"`
	Sid   string `json:"sid"`
	Code  string `json:"code"`
}

// 用户绑定手机号
func (that *MemberController) BindPhone(ctx *fasthttp.RequestCtx) {

	params := bindPhoneParam{}
	data := ctx.PostBody()
	err := json.Unmarshal(data, &params)
	if err != nil {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	ip := helper.FromRequest(ctx)
	err = model.CheckSmsCaptcha(ip, params.Sid, "55"+params.Phone, params.Code)
	if err != nil {
		helper.Print(ctx, false, helper.PhoneVerificationErr)
		return
	}

	err = model.MemberUpdatePhone(params.Ts, params.Phone, ctx)
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}

	helper.Print(ctx, true, helper.Success)
}

type updateInfoParam struct {
	Phone    string `json:"phone"`
	Email    string `json:"email"`
	Username string `json:"username"`
	//Telegram string `json:"telegram"`
}

func (that *MemberController) UpdateInfo(ctx *fasthttp.RequestCtx) {

	params := updateInfoParam{}
	data := ctx.PostBody()
	err := json.Unmarshal(data, &params)
	if err != nil {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	err = model.MemberUpdateInfo(ctx, params.Phone, params.Email, params.Username)
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}

	helper.Print(ctx, true, helper.Success)
}

// 游戏配置列表
func (that MemberController) TurntableSwitch(ctx *fasthttp.RequestCtx) {
	s := model.TurntableSwitch()
	helper.Print(ctx, true, s)
}

// 玩家汇总数据
func (that MemberController) MemberAccData(ctx *fasthttp.RequestCtx) {

	tAccu := userHelp.TblMemberAccu{}

	value := ctx.UserValue("token")
	if value == nil {
		helper.Print(ctx, false, tAccu)
	}

	uid := string(value.([]byte))
	tAccu.Uid = uid
	tAccu.Deposit = myUserHelp.GetTotalDeposit(uid)
	tAccu.DepositTimes = myUserHelp.GetDepositTime(uid)
	tAccu.Withdraw = myUserHelp.GetTotalWithdraw(uid)
	tAccu.WithdrawTimes = myUserHelp.GetWithdrawTime(uid)
	tAccu.Running = myUserHelp.GetTotalRunning(uid)
	tAccu.GameRound = myUserHelp.GetTotalGameRound(uid)
	tAccu.GameWinlost = myUserHelp.GetTotalGameWinLost(uid)
	tAccu.GameTax = myUserHelp.GetTotalGameTax(uid)
	tAccu.TurntableBonus = myUserHelp.GetTotalTurntableBonus(uid)

	helper.Print(ctx, true, tAccu)
}

type verificationPasswordParam struct {
	PayPassword string `json:"pay_password"` //支付密码
}

// 用户修改密码
func (that *MemberController) VerificationPayPassword(ctx *fasthttp.RequestCtx) {

	params := verificationPasswordParam{}
	data := ctx.PostBody()
	err := json.Unmarshal(data, &params)
	if err != nil {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	//if !validator.CtypeAlnum(params.PayPassword) {
	//	helper.Print(ctx, false, helper.PasswordFMTErr)
	//	return
	//}

	err = model.MemberPayPasswordVerification(params.PayPassword, ctx)
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}

	helper.Print(ctx, true, helper.Success)
}

type DepositBonusInfo struct {
	HasDepositBonus float64                                           `db:"has_deposit_bonus" json:"has_deposit_bonus"` //已领取金额
	InviteBonus     []myConfig.CfgProxyInviteBonusByDepositAmountItem `json:"invite_bonus"`                             //首充梯度奖励明细
	NeedWaged       float64                                           `db:"need_waged" json:"need_waged"`               //有效打码配置
}

// 首充梯度奖励
func (that *MemberController) GetFirstDepositBonusInfo(ctx *fasthttp.RequestCtx) {

	valUid := model.GetUidFromToken(ctx)
	if valUid == "" {
		helper.Print(ctx, false, helper.AccessTokenExpires)
		return
	}
	var depositBonus DepositBonusInfo
	sqlSelect := fmt.Sprintf("select ifnull(sum(enable_first_deposit_to_parent),0) as enable_first_deposit_to_parent from tbl_proxy_accu where uid=%s", valUid)
	selectErr := model.GetMasterDBInstance().Get(&depositBonus.HasDepositBonus, sqlSelect)
	if selectErr != nil {
		helper.InfoLog("[GetRechargeShareInfo]:%s error:%s", sqlSelect, selectErr.Error())
	}

	var cfg myConfig.CsProxyInviteBonusCfg
	depositBonus.InviteBonus = cfg.GetDepoistAmountCfg()
	depositBonus.NeedWaged = myConfig.GetGameCfgFloat64(myConfig.CfgFirstDepositBonusWaged)
	helper.Print(ctx, true, depositBonus)
	return
}

type DepositBonusRecordParam struct {
	BeginTime int   `json:"beginTime"`
	EndTime   int   `json:"endTime"`
	PageIndex int32 `json:"pageIndex"`
	PageCount int32 `json:"pageCount"`
}

type DepositBonusRecord struct {
	RecordCount       int                `db:"record_count" json:"record_count"`
	DepositBonusTotal DepositBonusTotal  `json:"deposit_bonus_total"`
	Items             []DepositBonusItem `db:"Items" json:"Items"`
}

type DepositBonusTotal struct {
	TotalDeposit float64 `db:"total_deposit" json:"total_deposit"`
	TotalBonus   float64 `db:"total_bonus" json:"total_bonus"`
}

type DepositBonusItem struct {
	Uid      int     `db:"uid" json:"uid"`
	Nickname string  `db:"nickname" json:"nickname"`
	ParentId int     `db:"parent_id" json:"parent_id"`
	Amount   float64 `db:"amount" json:"amount"`
	Level    int     `db:"level" json:"level"`
	Rate     float64 `db:"rate" json:"rate"`
	Bonus    float64 `db:"bonus" json:"bonus"`
	CreateAt int     `db:"create_at" json:"create_at"`
}

type LotteryInfo struct {
	DisplayStatus     int      `db:"display_status" json:"display_status"`         //展示状态
	CurrentIssue      string   `db:"current_issue" json:"current_issue"`           //当前期号
	StartTime         int64    `db:"start_time" json:"start_time"`                 //活动开始时间
	EndTime           int64    `db:"end_time" json:"end_time"`                     //活动结束时间
	PoolAmount        int      `db:"pool_amount" json:"pool_amount"`               //奖池金额（单位：分）
	Countdown         int64    `db:"countdown_s" json:"countdown_s"`               // 倒计时（单位：秒）
	ParticipantsCount int      `db:"participants_count" json:"participants_count"` // 参与人数
	RefreshIntervalS  int      `db:"refresh_interval_s" json:"refresh_interval_s"`
	Shares            int      `db:"shares" json:"shares"`                         //份额数
	TotalShares       int      `db:"total_shares" json:"total_shares"`             //总份额
	TopBroadcastList  []string `db:"top_broadcast_list" json:"top_broadcast_list"` //顶部显示
}
type LotteryItem struct {
	Username string  `db:"username" json:"username"`
	Level    string  `db:"level_desp" json:"prize_level"`
	Amount   float64 `db:"award" json:"amount"`
}

type LotteryAwardItem struct {
	Username string `db:"username" json:"username"`
	Amount   int    `db:"award" json:"amount"`
}

type LotteryResItem struct {
	LevelDesp string             `json:"prize_level"`
	AwardLst  []LotteryAwardItem `json:"user_id"`
}

type MyLotteryRes struct {
	SerialNo      string  `db:"serial_no" json:"serial_no"`
	Uid           string  `db:"uid" json:"uid"`
	PrizeLevel    string  `db:"level_desp" json:"prize_level"`
	LotteryAmount float64 `db:"award" json:"lottery_amount"`
}

type LotteryRes struct {
	Reslst  []LotteryResItem `json:"winners"`
	MyAward MyLotteryRes     `json:"myaward"`
}

// PrizeRule 表示一个奖项规则
type LotteryPrizeRule struct {
	Rank       string  `json:"rankname" db:"rankname" cbor:"rankname"`
	Percentage float64 `json:"rate" db:"rate" cbor:"rate"`
	Count      int     `json:"count" db:"count" cbor:"count"`
}

func (that *MemberController) LotteryRule(ctx *fasthttp.RequestCtx) {

	var prizeRules []LotteryPrizeRule
	sqlSelect := fmt.Sprintf("SELECT rankname,rate,count from tbl_cfg_lottery_prize_rule order by count asc ")
	err := myredis.GetMasterDBInstance().Select(&prizeRules, sqlSelect)
	if err != nil {
		//没有游戏规则
		helper.SqlErrLog("LotteryRule prize:%s----%s", sqlSelect, err.Error())
		helper.Print(ctx, false, prizeRules)
		return
	}

	helper.Print(ctx, true, prizeRules)
}
func (that *MemberController) LotteryRec(ctx *fasthttp.RequestCtx) {

	var MaxSerialNo string = ""
	SqlMax := fmt.Sprintf("SELECT MAX(serial_no)FROM tbl_rec_lottery;")
	myredis.GetMasterDBInstance().Get(&MaxSerialNo, SqlMax)

	var Winners []LotteryItem
	SqlSelect := fmt.Sprintf("select username,level_desp,award from tbl_rec_lottery "+
		"where serial_no='%s' order by level_desp", MaxSerialNo)
	err := myredis.GetMasterDBInstance().Select(&Winners, SqlSelect)

	if err != nil {
		helper.SqlSelectErrLog("LotteryRec:%s-----%s", err.Error(), SqlSelect)
	}

	var Res LotteryRes
	for i, _ := range Winners {
		despKey := Winners[i].Level
		var bFound bool = false
		for j, _ := range Res.Reslst {
			if Res.Reslst[j].LevelDesp == despKey {
				bFound = true
				var AwardItem LotteryAwardItem
				AwardItem.Username = Winners[i].Username
				AwardItem.Amount = int(Winners[i].Amount)
				Res.Reslst[j].AwardLst = append(Res.Reslst[j].AwardLst, AwardItem)
				break
			}
		}

		if !bFound {
			var resItem LotteryResItem
			resItem.LevelDesp = despKey

			var AwardItem LotteryAwardItem
			AwardItem.Username = Winners[i].Username
			AwardItem.Amount = int(Winners[i].Amount)
			resItem.AwardLst = append(resItem.AwardLst, AwardItem)
			Res.Reslst = append(Res.Reslst, resItem)
		}
	}

	Uid := model.GetUidFromToken(ctx)
	if Uid != "" {
		sqlSelct := fmt.Sprintf("SELECT serial_no,uid,level_desp,award FROM tbl_rec_lottery "+
			"	where uid='%s' and serial_no='%s';", Uid, MaxSerialNo)
		myredis.GetMasterDBInstance().Get(&Res.MyAward, sqlSelct)
	}

	helper.Print(ctx, true, Res)
}
func (that *MemberController) LotteryInfo(ctx *fasthttp.RequestCtx) {
	valUid := model.GetUidFromToken(ctx)

	param := LotteryInfo{}

	if valUid == "" {
		param.Shares = 0
	} else {
		param.Shares = (int)(userHelp.GetLotteryDeposit(valUid)) / myConfig.G_LotteryCfg.MinRechargeAmount
	}

	param.DisplayStatus = myConfig.G_LotteryCfg.IsEnabled
	param.CurrentIssue = userHelp.G_LotteryBaseInfo.SerialNo
	param.StartTime = userHelp.G_LotteryBaseInfo.BeginTimeStamp
	param.EndTime = userHelp.G_LotteryBaseInfo.EndTimeStamp
	param.PoolAmount = userHelp.GetH5TotalAward()
	param.Countdown = userHelp.G_LotteryBaseInfo.EndTimeStamp - time.Now().Unix()
	param.ParticipantsCount = userHelp.G_LotteryBaseInfo.JoinInPerson
	param.RefreshIntervalS = myConfig.G_LotteryCfg.H5Refresh
	param.TotalShares = userHelp.G_LotteryBaseInfo.TotalShare

	for _, str := range userHelp.G_RecentJoinPerson {
		if str != "" {
			param.TopBroadcastList = append(param.TopBroadcastList, str)
		}
	}

	helper.Print(ctx, true, param)
}

// 首充梯度奖励记录
func (that *MemberController) FirstDepositBonusRecord(ctx *fasthttp.RequestCtx) {
	valUid := model.GetUidFromToken(ctx)
	if valUid == "" {
		helper.Print(ctx, false, helper.AccessTokenExpires)
		return
	}

	param := DepositBonusRecordParam{}
	dataBody := ctx.PostBody()
	err := json.Unmarshal(dataBody, &param)
	if err != nil {
		fmt.Println("json.Unmarshal err = ", err.Error())
		helper.Print(ctx, false, helper.ParamErr)
		return
	}

	//先查询总条数跟汇总
	var record DepositBonusRecord
	sqlSelect := fmt.Sprintf("select count(1) as recordCount "+
		"from tbl_rec_first_deposit_bonus where parent_id=%s and state=1 ", valUid)

	if param.BeginTime != 0 && param.EndTime != 0 {
		sqlSelect += fmt.Sprintf(" and create_at>=%d and create_at<=%d", param.BeginTime, param.EndTime)
	}

	//获取总的记录数量
	model.GetMasterDBInstance().Get(&record.RecordCount, sqlSelect)

	//获取汇总
	sqlSelect = fmt.Sprintf("select IFNULL(SUM(amount), 0)  as total_deposit,IFNULL(SUM(bonus), 0)  as total_bonus "+
		"from tbl_rec_first_deposit_bonus where parent_id=%s  and state=1 ", valUid)
	model.GetMasterDBInstance().Get(&record.DepositBonusTotal, sqlSelect)

	sqlSelect = fmt.Sprintf("select uid,nickname,parent_id,amount,level,rate,bonus,create_at "+
		"from tbl_rec_first_deposit_bonus where parent_id=%s and state=1 ", valUid)

	if param.BeginTime != 0 && param.EndTime != 0 {
		sqlSelect += fmt.Sprintf(" and create_at>=%d and create_at<=%d", param.BeginTime, param.EndTime)
	}

	sqlSelect += fmt.Sprintf(" order by create_at")
	sqlSelect += fmt.Sprintf("  LIMIT %d OFFSET %d", param.PageCount, param.PageIndex*param.PageCount)

	err = model.GetMasterDBInstance().Select(&record.Items, sqlSelect)
	if err != nil {
		helper.SqlSelectErrLog("%s--%s", sqlSelect, err.Error())
	}
	helper.Print(ctx, true, record)
}

func (that *MemberController) VerifyInfo(ctx *fasthttp.RequestCtx) {

	uid := model.GetUidFromToken(ctx)
	if uid == "" {
		helper.Print(ctx, false, helper.AccessTokenExpires)
		return
	}
	mb, err := model.GetMemberVerifyInfo(uid)
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}

	helper.Print(ctx, true, mb)
}

// 用户绑定cpf
func (that *MemberController) UpdateVerifyInfo(ctx *fasthttp.RequestCtx) {

	params := model.TblMemberVerify{}
	data := ctx.PostBody()
	err := json.Unmarshal(data, &params)
	if err != nil {
		helper.Print(ctx, false, helper.ParamErr)
		return
	}
	uid := model.GetUidFromToken(ctx)
	if uid == "" {
		helper.Print(ctx, false, helper.AccessTokenExpires)
		return
	}
	params.Uid = uid
	err = model.MemberVerifyInfo(params)
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}

	helper.Print(ctx, true, helper.Success)
}

func (that *MemberController) DepositInfo(ctx *fasthttp.RequestCtx) {

	uid := model.GetUidFromToken(ctx)
	if uid == "" {
		helper.Print(ctx, false, helper.AccessTokenExpires)
		return
	}
	mb, err := model.GetMemberDepositInfo(uid)
	if err != nil {
		helper.Print(ctx, false, err.Error())
		return
	}

	helper.Print(ctx, true, mb)
}
